var Report = {
	Detail: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Report/' + language + '.js');
			Utils.initAjax();
			
			Report.Detail.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Report.Detail.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Report.Detail.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				startDateboxLabelContainer: '',
				startDateboxInputContainer: '',
				endDateboxLabelContainer: '',
				endDateboxInputContainer: '',
				reportTypeComboboxLabelContainer: '',
				reportTypeComboboxInputContainer: '',
				searchButtonContainer: '',
				
				init: function() {
					Report.Detail.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Report.Detail.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Report.Detail.View.DataGrid.startDateboxLabelContainer = $('#dataGridPanel #toolbar #startDateboxLabel');
					Report.Detail.View.DataGrid.startDateboxInputContainer = $('#dataGridPanel #toolbar #startDateboxInput');
					Report.Detail.View.DataGrid.endDateboxLabelContainer = $('#dataGridPanel #toolbar #endDateboxLabel');
					Report.Detail.View.DataGrid.endDateboxInputContainer = $('#dataGridPanel #toolbar #endDateboxInput');
					Report.Detail.View.DataGrid.reportTypeComboboxLabelContainer = $('#dataGridPanel #toolbar #reportTypeComboboxLabel');
					Report.Detail.View.DataGrid.reportTypeComboboxInputContainer = $('#dataGridPanel #toolbar #reportTypeComboboxInput');
					Report.Detail.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Report.Detail.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Report.Detail.View.dataGridPanelContainer.width(width);
					Report.Detail.View.dataGridPanelContainer.height(height);
					Report.Detail.View.dataGridPanelContainer.datagrid({
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'datetime',
								title: reportDetailViewDataGridColumnTitle1,
								width: 130,
							},
							{
								field: 'operatorName',
								title: reportDetailViewDataGridColumnTitle2,
								width: 60,
							},
							{
								field: 'areaNum',
								title: reportDetailViewDataGridColumnTitle3,
								width: 50,
							},
							{
								field: 'registerAccountNum',
								title: reportDetailViewDataGridColumnTitle4,
								width: 60,
							},
							{
								field: 'createRoleNum',
								title: reportDetailViewDataGridColumnTitle6,
								width: 60,
							},
							{
								field: 'totalRegisterNum',
								title: reportDetailViewDataGridColumnTitle30,
								width: 60,
							},
							{
								field: 'totalCreateRoleNum',
								title: reportDetailViewDataGridColumnTitle31,
								width: 60,
							},
//							{
//								field: 'registerIpAddressNum',
//								title: reportDetailViewDataGridColumnTitle5,
//								width: 50,
//							},
							{
								field: 'createRolePercent',
								title: reportDetailViewDataGridColumnTitle7,
								width: 60,
								formatter: function(value, rowData) {
									if(rowData.registerAccountNum === '0') {
										var createRolePercent = 0;
									}
									else {
										var createRolePercent = rowData.createRoleNum / rowData.registerAccountNum * 100;
									}

									return createRolePercent.toFixed(2) + '%';
								}
							
							},
							{
								field: 'maxOnlineRoleNum',
								title: reportDetailViewDataGridColumnTitle8,
								width: 60,
							},
							{
								field: 'avgOnlineRoleNum',
								title: reportDetailViewDataGridColumnTitle9,
								width: 60,
							},
							{
								field: 'loginAccountNum',
								title: reportDetailViewDataGridColumnTitle11,
								width: 60,
							},
//							{
//								field: 'loginIpAddressNum',
//								title: reportDetailViewDataGridColumnTitle12,
//								width: 50,
//							},
//							{
//								field: 'loginDivMaxOnline',
//								title: reportDetailViewDataGridColumnTitle10,
//								width: 60,
//								formatter: function(value, rowData) {
//									//if(rowData.maxOnlineRoleNum === '0') {
//									//	var loginDivMaxOnline = 0;
//									//}
//									//else {
//									//	var loginDivMaxOnline = rowData.loginAccountNum / rowData.maxOnlineRoleNum;
//									//}
//									return  rowData.loginAccountNum - rowData.createRoleNum;
//								}
//							},
							
							{
								field: 'totalPay',
								title: reportDetailViewDataGridColumnTitle29,
								width: 80,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							{
								field: 'totalPayAccountNum',
								title: reportDetailViewDataGridColumnTitle32,
								width: 70,
							},
							{
								field: 'payMoney',
								title: reportDetailViewDataGridColumnTitle13,
								width: 80,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							{
								field: 'payAccountNum',
								title: reportDetailViewDataGridColumnTitle14,
								width: 60,
							},{
								field: 'payRateNum',
								title: reportDetailViewDataGridColumnTitle15,
								width: 60,
								formatter: function(value) {
									if(value === '0') {
										var percent = 0;
									}
									else {
										var percent = value * 100;
									}

									return percent.toFixed(2) + '%';
								}
							},{
								field: 'arpu',
								title: reportDetailViewDataGridColumnTitle16,
								width: 60,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},{
								field: 'arppu',
								title: reportDetailViewDataGridColumnTitle17,
								width: 60,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							
							//
							{
								field: 'payMoneyNew',
								title: reportDetailViewDataGridColumnTitle18,
								width: 80,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							{
								field: 'payAccountNumNew',
								title: reportDetailViewDataGridColumnTitle19,
								width: 70,
							},{
								field: 'payRateNumNew',
								title: reportDetailViewDataGridColumnTitle20,
								width: 70,
								formatter: function(value) {
									if(value === '0') {
										var percent = 0;
									}
									else {
										var percent = value * 100;
									}

									return percent.toFixed(2) + '%';
								}
							},{
								field: 'arpuNew',
								title: reportDetailViewDataGridColumnTitle21,
								width: 70,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},{
								field: 'arppuNew',
								title: reportDetailViewDataGridColumnTitle22,
								width: 70,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							
							//
							{
								field: 'payMoneyOld',
								title: reportDetailViewDataGridColumnTitle23,
								width: 80,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							{
								field: 'payAccountNumOld',
								title: reportDetailViewDataGridColumnTitle24,
								width: 70,
							},{
								field: 'payRateNumOld',
								title: reportDetailViewDataGridColumnTitle25,
								width: 70,
								formatter: function(value) {
									if(value === '0') {
										var percent = 0;
									}
									else {
										var percent = value * 100;
									}

									return percent.toFixed(2) + '%';
								}
							},{
								field: 'arpuOld',
								title: reportDetailViewDataGridColumnTitle26,
								width: 70,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},{
								field: 'arppuOld',
								title: reportDetailViewDataGridColumnTitle27,
								width: 70,
								formatter: function(value) {
									var money = value / 100;
									return money.toFixed(2);
								}
							},
							
							{
								field: 'monthCardNum',
								title: reportDetailViewDataGridColumnTitle28,
								width: 70,
							},
							{
								field: 'superCardNum',
								title: reportDetailViewDataGridColumnTitle33,
								width: 70,
							},
							{
								field: 'bothCardNum',
								title: reportDetailViewDataGridColumnTitle34,
								width: 70,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Report.Detail.View.DataGrid.gameAreaCombogridLabelContainer,
						Report.Detail.View.DataGrid.gameAreaCombogridInputContainer,
						true
					);
					Component.Datebox.Start.create(
						Report.Detail.View.DataGrid.startDateboxLabelContainer,
						Report.Detail.View.DataGrid.startDateboxInputContainer
					);
					Component.Datebox.End.create(
						Report.Detail.View.DataGrid.endDateboxLabelContainer,
						Report.Detail.View.DataGrid.endDateboxInputContainer
					);
					Component.Combobox.ReportType.create(
						Report.Detail.View.DataGrid.reportTypeComboboxLabelContainer,
						Report.Detail.View.DataGrid.reportTypeComboboxInputContainer
					);
					Report.Detail.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: reportDetailViewDataGridToolbarButtonText1,
					});
					Report.Detail.View.DataGrid.searchButtonContainer.bind(
						'click',
						Report.Detail.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					var gameAreaIdArray = Report.Detail.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValues');
					var startDate = Report.Detail.View.DataGrid.startDateboxInputContainer.datebox('getValue');
					var endDate = Report.Detail.View.DataGrid.endDateboxInputContainer.datebox('getValue');
					var reportTypeId = Report.Detail.View.DataGrid.reportTypeComboboxInputContainer.combobox('getValue');
					
					Report.Detail.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Report/detail/getListData',
						queryParams: {
							gameAreaIdString: gameAreaIdArray.toString(),
							startDate: startDate,
							endDate: endDate,
							reportTypeId: reportTypeId,
						}
					});
				},
			},
		},
	},

	Level: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Report/' + language + '.js');
			Utils.initAjax();
			
			Report.Level.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Report.Level.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Report.Level.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				searchDateboxLabelContainer: '',
				searchDateboxInputContainer: '',
				searchButtonContainer: '',
				
				init: function() {
					Report.Level.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Report.Level.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Report.Level.View.DataGrid.searchDateboxLabelContainer = $('#dataGridPanel #toolbar #searchDateboxLabel');
					Report.Level.View.DataGrid.searchDateboxInputContainer = $('#dataGridPanel #toolbar #searchDateboxInput');
					Report.Level.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Report.Level.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Report.Level.View.dataGridPanelContainer.width(width);
					Report.Level.View.dataGridPanelContainer.height(height);
					Report.Level.View.dataGridPanelContainer.datagrid({
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'level',
								title: reportLevelViewDataGridColumnTitle1,
								width: 100,
							},
							{
								field: 'roleNum',
								title: reportLevelViewDataGridColumnTitle2,
								width: 100,
							},
							{
								field: 'payRoleNum',
								title: reportLevelViewDataGridColumnTitle3,
								width: 100,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Report.Level.View.DataGrid.gameAreaCombogridLabelContainer,
						Report.Level.View.DataGrid.gameAreaCombogridInputContainer
					);
					Component.Datebox.Search.create(
						Report.Level.View.DataGrid.searchDateboxLabelContainer,
						Report.Level.View.DataGrid.searchDateboxInputContainer
					);
					Report.Level.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: reportLevelViewDataGridToolbarButtonText1,
					});
					Report.Level.View.DataGrid.searchButtonContainer.bind(
						'click',
						Report.Level.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					var gameAreaId = Report.Level.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValue');
					var searchDate = Report.Level.View.DataGrid.searchDateboxInputContainer.datebox('getValue');
					
					Report.Level.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Report/level/getListData',
						queryParams: {
							gameAreaId: gameAreaId,
							date: searchDate,
						}
					});
				},
			},
		},
	},
	
	Remain: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Report/' + language + '.js');
			Utils.initAjax();
			
			Report.Remain.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Report.Remain.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Report.Remain.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				searchButtonContainer: '',
				
				init: function() {
					Report.Remain.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Report.Remain.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Report.Remain.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Report.Remain.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Report.Remain.View.dataGridPanelContainer.width(width);
					Report.Remain.View.dataGridPanelContainer.height(height);
					Report.Remain.View.dataGridPanelContainer.datagrid({
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'operatorName',
								title: reportRemainViewDataGridColumnTitle1,
								width: 80,
							},
							{
								field: 'areaNum',
								title: reportRemainViewDataGridColumnTitle2,
								width: 60,
							},
							{
								field: 'registerDate',
								title: reportRemainViewDataGridColumnTitle3,
								width: 100,
							},
							{
								field: 'day1',
								title: reportRemainViewDataGridColumnTitle4,
								width: 100,
							},
							{
								field: 'day2',
								title: reportRemainViewDataGridColumnTitle5,
								width: 100,
							},
							{
								field: 'day3',
								title: reportRemainViewDataGridColumnTitle6,
								width: 100,
							},
							{
								field: 'day4',
								title: reportRemainViewDataGridColumnTitle7,
								width: 100,
							},
							{
								field: 'day5',
								title: reportRemainViewDataGridColumnTitle8,
								width: 100,
							},
							{
								field: 'day6',
								title: reportRemainViewDataGridColumnTitle9,
								width: 100,
							},
							{
								field: 'day14',
								title: reportRemainViewDataGridColumnTitle10,
								width: 100,
							},
							{
								field: 'day29',
								title: reportRemainViewDataGridColumnTitle11,
								width: 100,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Report.Remain.View.DataGrid.gameAreaCombogridLabelContainer,
						Report.Remain.View.DataGrid.gameAreaCombogridInputContainer,
						true
					);
					Report.Remain.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: reportRemainViewDataGridToolbarButtonText1,
					});
					Report.Remain.View.DataGrid.searchButtonContainer.bind(
						'click',
						Report.Remain.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					Report.Remain.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Report/remain/getListData',
						queryParams: {
							gameAreaId: Report.Remain.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValue'),
						}
					});
				},
			},
		},
	},
}